package com.thinkgem.jeesite.common.exception;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 捕获特定异常，显示友好页面。
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 用户无shiro权限
     * @param req
     * @param e
     * @return
     */
    @ExceptionHandler(value = UnauthorizedException.class)
    @ResponseBody
    public String exceptionHandler(HttpServletRequest req, Exception e){
        String requestURI = req.getRequestURI();
        String return_s=requestURI+" is error :"+e.getMessage();
        return return_s;
    }

}